<template>
  <div class="goods">
    <page-search
      :searchFormConfig="searchFormConfig"
      @resetBtnClick="handleResetBtn"
      @searchBtnClick="handleSearchBtn"
    ></page-search>
    <page-content
      :contentTableConfig="contentTableConfig"
      pageName="goods"
      ref="pageContentRef"
    >
      <template #image="scope">
        <el-image
          style="width: 50px; height: 50px"
          :src="scope.row.imgUrl"
          :preview-src-list="[scope.row.imgUrl]"
        >
        </el-image>
      </template>
      <template #oldPrice="scope">{{ '¥' + scope.row.oldPrice }}</template>
      <template #newPrice="scope">{{ '¥' + scope.row.newPrice }}</template>
    </page-content>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'

import pageSearch from '@/components/page-search'
import pageContent from '@/components/page-content'

import { contentTableConfig } from './config/content-config'
import { searchFormConfig } from './config/search-config'

import { usePageSearch } from '@/hooks/usePageSearch'

export default defineComponent({
  name: 'goods',
  components: {
    pageSearch,
    pageContent
  },
  setup() {
    const [pageContentRef, handleResetBtn, handleSearchBtn] = usePageSearch()

    return {
      contentTableConfig,
      searchFormConfig,
      pageContentRef,
      handleResetBtn,
      handleSearchBtn
    }
  }
})
</script>

<style scoped></style>
